#pragma once

#include <cstddef>
#include <array>
#include <chrono>
namespace memory_pool {

constexpr size_t MAX_BYTES = 256 * 1024; // 256KB
constexpr size_t ALIGNMENT = 8;
constexpr size_t FREE_LIST_SIZE = MAX_BYTES / ALIGNMENT;
// 内存块头部信息
struct BlockHeader {
    size_t size;
    bool inUse;
    BlockHeader* next;
};
// 大小类管理
class SizeClass {
public:
    // 向上取整 将bytes向上取整到ALIGNMENT的倍数
    static size_t roundUp(size_t bytes) {
        return (bytes + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
    }
    // 获取下标
    static size_t getIndex(size_t bytes) {
        return (bytes + ALIGNMENT - 1) / ALIGNMENT - 1;
    }
};

}